<template>
  <div class='userstaking'>

<el-col :span="24" class="toolbar" style="padding-bottom: 0px;padding-bottom: 0px;
    display: flex;justify-content: space-between">

      <el-form :inline="true" :model="userStakingListMsg">
        <el-form-item>
          <el-input
            v-model="userStakingListMsg.uid"
            :placeholder="$t('iptdefault.username')"
          ></el-input>
        </el-form-item>

          <el-select v-model="userStakingListStatus.status" :placeholder="$t('userlist.status')" @change="currentSel">
          <el-option
            v-for="item in userStakingListStatusSelect"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>

        <el-form-item>
          <el-button type="primary" v-on:click="getuserStaklistbtn">{{$t('publicbtn.query')}}</el-button>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="getuserStakRefresh">{{$t('publicbtn.refresh')}}</el-button>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="newgetuserStakPledgefalse=true">{{$t('field.newpledged')}}</el-button>
        </el-form-item>

      </el-form>

      <el-form :inline="true" style="display:flex;align-item:center;">
        <el-form-item>
          <el-button type="primary" @click="exportexcel">{{$t('publicbtn.exportalldata')}}</el-button>
        </el-form-item>
       <excelexport></excelexport>
      </el-form>
    </el-col>

    <!-- 列表 -->
 <el-table
      v-loading="loading"
      :data="userStakingList"
      style="width: 100%"
      id="out-table">
    <el-table-column prop="userId" :label="$t('field.userid')" width="130" fixed="left"></el-table-column>
    <el-table-column prop="name" :label="$t('field.upusername')" width="130" fixed="left"></el-table-column>
    <el-table-column prop="username" :label="$t('field.cellphones')" width="130" fixed="left"></el-table-column>
    <el-table-column prop="crypto" :label="$t('field.currency')" width="130"></el-table-column>
    <el-table-column prop="type"  :label="$t('field.type')" width="130">
        <template slot-scope="props">
          {{
            props.row.type == 1 ? $t('field.current'): props.row.type == 2 ?$t('field.regular')+'('+ props.row.lockDay+$t('field.day')+')':''
          }}
        </template>
    </el-table-column>
    <el-table-column prop="createdAt" :label="$t('field.dateofapplication')" width="130"></el-table-column>
    <el-table-column prop="endDate" :label="$t('field.redemptiontime')" width="130">
         <template slot-scope="props">
          {{
            props.row.endDate | formatDate
          }}
        </template>
    </el-table-column>
    <el-table-column prop="unlockDay" :label="$t('field.currentrelease')" width="130"></el-table-column>
    <el-table-column prop="num" :label="$t('field.pledgequantity')" width="130">
        <template slot-scope="props">
          {{
          (Math.abs(props.row.num)  / million).toFixed(8)
          }}
        </template>
    </el-table-column>
    <el-table-column prop="interestTotal" :label="$t('field.accumulatedinterest')" width="130">
       <template slot-scope="props">
          {{
          (props.row.interestTotal / million).toFixed(8)
          }}
        </template>
    </el-table-column>
    <el-table-column prop="cycle" :label="$t('field.poayoutperio')" width="130"></el-table-column>
    <el-table-column prop="rate" :label="$t('field.interest')" width="130">
        <template slot-scope="props">
          {{
            (props.row.rate * 100).toFixed(1)+'%'
          }}
        </template>
    </el-table-column>
    <el-table-column prop="status" :label="$t('field.status')" width="130">
       <template slot-scope="props">
          {{
            props.row.status == 0 ?$t('field.inposition'): props.row.status == 1 ?$t('field.inredemption'): props.row.status == -1 ?$t('field.foreclosure'):props.row.status == -2 ?$t('field.close'):''
          }}
        </template>
    </el-table-column>
    <el-table-column prop="num" :label="$t('field.operation')" width="270" fixed="right">
      <template slot-scope="props">
          <el-button
            size="mini" 
            @click="upUserStakingList(props.row.cycle,props.row.orderId,props.row.rate)">
            {{$t('publicbtn.modifyinformation')}}
          </el-button>

          <el-button 
            size="mini"
            type="primary"
            @click="upUserRedemptionList(props.row)"
          >
          {{$t('publicbtn.redemption')}}
          </el-button>
          
          <el-button
          
            size="mini"
            type="primary"
            @click="upUserStakingListdelect(props.row)"
          >      {{$t('publicbtn.delete')}}

          </el-button>
        </template>
    </el-table-column>
</el-table>

  <!--修改 -->
    <div class="userUpdateMoney" v-show='upUserStakingListMsg'>
      <div class="userUpdateForm">
        <h2>{{$t('field.modify')}}</h2>
          <el-form
          :model="upUserStakingListdata"
          ref="getupdatanewdata"
          label-width="100px"
          class="demo-updateForm">

          <div style="display: flex">

            <div class="updateLeft">
              <el-form-item label-width="140px" :label="$t('field.orderId')" prop="orderId">

                <el-input
                  v-model="upUserStakingListdata.orderId"
                  disabled
                ></el-input>
              </el-form-item>

              <el-form-item label-width="140px" :label="$t('field.payoutperiod')" prop="cycle">
                <el-input
                  v-model="upUserStakingListdata.cycle"
                  :placeholder="$t('iptdefault.pleaseminutes')"
                ></el-input>
              </el-form-item>

               <el-form-item label-width="140px" :label="$t('field.interest')" prop="rate">
                <el-input
                  v-model="upUserStakingListdata.rate"
                  :placeholder="$t('iptdefault.annualinterest')"
                ></el-input>
              </el-form-item>


              </div>

          </div>

          <el-form-item style="text-align: center">
            <el-button type="primary" @click="upUserStakingSubmit"
              >{{$t('publicbtn.updatenow')}}</el-button
            >
            <el-button @click="upUserStakingSubmitReset">{{$t('publicbtn.cancel')}}</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>

    <!-- 新增质押 -->
    <div class="userUpdateMoney" v-show='newgetuserStakPledgefalse'>
      <div class="userUpdateForm">
        <h2>{{$t('field.newpledged')}}</h2>
          <el-form
          :model="newUserPledgedata"

          :rules='newUserrules'
          ref="newUserPledgedata"
          label-width="100px"
          class="demo-updateForm">

          <div class="newgetusermsgdata">

            <div class="updateLeft newgetuser">
              
              <el-form-item  label-width="120px" :label="$t('field.upusername')" prop="orderId">
                <el-input
                  v-model="searchuserdata.username"
                  :placeholder="$t('iptdefault.username')"
                  >
                  </el-input>
              </el-form-item>

               <el-form-item label-width="120px" :label="$t('field.digitalcurrencys')" prop="orderId">
                <el-input

                  :placeholder="$t('tradewallet.currencyname')"
                  v-model="searchuserdata.crypto">
                  </el-input>
              </el-form-item>

                <el-form-item>
                <el-button type="primary" @click="newSearch">{{$t('field.search')}}</el-button>
              </el-form-item>
              </div>
              <div style="display:flex">
<!-- fnehuan  -->
            <div>

              <el-form-item label-width="120px" :label="$t('field.upbalance')" prop="amount">
                <el-input
                  v-model="newUserPledgedata.amount"
                  disabled>
                  </el-input>
              </el-form-item>
              
              <el-form-item label-width="120px" label='UID' prop="uid">
                <el-input
                  v-model="newUserPledgedata.uid"
                  disabled>
                  </el-input>
              </el-form-item>

               <el-form-item label-width="120px" :label="$t('field.cellphone')" prop="username">
                <el-input
                  v-model="newUserPledgedata.username"
                  disabled>
                  </el-input>
              </el-form-item>


              <el-form-item label-width="120px" :label="$t('field.username')" prop="name">
                <el-input
                  v-model="newUserPledgedata.name"
                  disabled>
                  </el-input>
              </el-form-item>

              
              <el-form-item label-width="120px" :label="$t('field.userid')" prop="userId">
                <el-input
                  v-model="newUserPledgedata.userId"
                  disabled>
                  </el-input>
              </el-form-item>
                          
             <el-form-item label-width="120px" :label="$t('stakinglist.payoutperiod')" prop="cycle">
                <el-input
                  v-model="newUserPledgedata.cycle"
                  :placeholder="$t('iptdefault.pleaseminutes')"
                  :disabled = disabledratecycle.cycleipt
                  >
                  </el-input>
              </el-form-item> 



            </div>
            <div>

             <el-form-item label-width="120px" :label="$t('field.pledgequantity')" prop="num">
                <el-input
                  v-model="newUserPledgedata.num"
                  :placeholder="$t('iptdefault.currentrelease')"
                  >
                  </el-input>
              </el-form-item>

               <el-form-item label-width="120px" :label="$t('field.interest')" prop="rate">
                <el-input
                  v-model="newUserPledgedata.rate"
                  :placeholder="$t('iptdefault.annualinterest')"
                  :disabled = disabledratecycle.rateipt>
                  </el-input>
              </el-form-item>
              
                 <el-form-item label-width="120px" :label="$t('field.type')" prop="type">
                    <el-select @change = 'changeType'
                  v-model="newUserPledgedata.type"
                        :placeholder="$t('stakinglist.iptcurrent')">
                  <el-option :label="$t('stakinglist.current')" :value="1"></el-option>
                  <el-option :label="$t('stakinglist.regular')" :value="2"></el-option>
                </el-select>
              </el-form-item>

             
              <el-form-item label-width="120px" :label="$t('stakinglist.unlockingperiod')" prop="unlockDay">
                <el-input
                  :placeholder="$t('stakinglist.iptunlockingperiod')"
                  v-model="newUserPledgedata.unlockDay"
                  :disabled="disabled.disabledhouqi">
                  </el-input>
              </el-form-item>

                  <el-form-item label-width="120px" :label="$t('stakinglist.nvestmentperiod')" prop="lockDay">
                <el-input
                  :placeholder="$t('stakinglist.iptnvestmentperiod')"

                  v-model="newUserPledgedata.lockDay"
                  :disabled="disabled.disabledsiqi">
                  </el-input>
              </el-form-item>  
            </div>

              </div>
          </div>

          <el-form-item style="text-align: center">
            <el-button type="primary" @click="newgetuserStakPledgedatasubmit('newUserPledgedata')"
              >{{$t('publicbtn.submitbtn')}}</el-button
            >
            <el-button @click="newgetuserStakPledgefalseclose">{{$t('publicbtn.cancel')}}</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  <!-- 导出全部数据 -->
    <div class="userUpdateMoney" v-show="userstakinglist.show">
         <div class="userUpdateForm">
             <h2>{{$t('publicbtn.exportalldata')}}</h2>
                     <el-form ref="userstakinglist" label-width="90px" class="demo-ruleForm">
                      
                        <el-form-item :required="true" :label="$t('userlist.Statusinformation')">
                          <el-select v-model="userstakinglist.status" :placeholder="$t('userlist.pleaseselectstatusinformation')">
                            <el-option
                              v-for="item in userStakingListStatusSelect"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>

                        <el-form-item :label="$t('userlist.startpage')">
                            <el-input
                              label-width="90px"
                                :placeholder="$t('iptdefault.startpage')"
                              v-model="userstakinglist.start" onkeyup="this.value=this.value.replace(/\D/g,'')"

                              autocomplete="off"
                            ></el-input>
                        </el-form-item>

                        <el-form-item :label="$t('userlist.endpage')">
                        <el-input
                          label-width="90px"
                             :placeholder="$t('iptdefault.endpage')"
                          v-model="userstakinglist.end" onkeyup="this.value=this.value.replace(/\D/g,'')"
                    
                          autocomplete="off"
                        ></el-input>
                        </el-form-item>
                        
                        <el-form-item>
                          <el-button type="primary" @click="exportUserstakingSubmit"
                            >{{$t('publicbtn.submitbtn')}}</el-button>
                          <el-button @click="exportUserstakingReset">{{$t('publicbtn.cancel')}}</el-button>
                        </el-form-item>

                     </el-form>
         </div>
    </div>



     <!--分页 -->
    <div class="pagination">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="userStakingListMsgtotal"
        :page-size="userStakingListMsg.size"
        @current-change="current_changes"
        :current-page="userStakingListMsg.page"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import exportData from "@/components/export.js";
import excelexport from '@/components/export.vue'
import {postUserRequest, getUserRequest,getUserStakingDelete } from "@/api/api";
export default {
    name:'userstaking',
        components:{
        excelexport
    },
  data() {
    return {
    userstakinglist:{
        show:false,
        start:null,
        end:null,
        status:1,
        },
    userStakingListdingqi:[],
    userStakingListhuoqi:[],
    upUserStakingListMsg:false,
    userStakingListStatus:{
        status:1
    },
    userStakingListStatusSelect:[
        {
            label:this.$t('field.current'),
            value:1,
        },
        {
             label:this.$t('field.regular'),
            value:2
        }
    ],
    loading:true,
    userStakingListMsgtotal:null,
    userStakingList:[],
    userStakingListMsg:{
       
        page:1,
        size:10,
        uid:'',
    },
    upUserStakingListdata:{
        orderId:null,
        cycle:null,
        rate:null,
    },
    newgetuserStakPledgefalse:false,
    searchuserdata:{
      type:1,
      crypto:'',
      username:''
    },
    newUserPledgedata:{
      amount:'',
      crypto:'',
      uid:'',
      userId:'',
      username:'',
      name:'',
      lockDay:'',
      
      num:'',
      rate:'',
      type:'',
      unlockDay:'',
      cycle:'',
    },
     disabled:{
      disabledhouqi:true,
      disabledsiqi:true
      },
      disabledratecycle:{
        cycleipt:true,
        rateipt:true
      },
      newUserrules:{
       
        num:[
          { required: true, message: this.$t('iptdefault.currentrelease'), trigger: 'blur' },
          { required: true,pattern:/^\d+(\.\d+)?$/, message:  this.$t('publicbtn.integerscanbeentered'), trigger: 'blur'}
        ],
        rate:[
          { required: true,  message:this.$t('iptdefault.annualinterest') , trigger: 'blur' },
          { required: true,pattern:/^\d+(\.\d+)?$/, message:  this.$t('publicbtn.integerscanbeentered'), trigger: 'blur'}
        ],
        type:[
           { required: true, message: this.$t('stakinglist.iptcurrent'), trigger: 'blur' },

        ],
       
        cycle:[
          { required: true, message: this.$t('iptdefault.pleaseminutes'), trigger: 'blur' },
          { required: true,pattern:/^\d+$/, message:  this.$t('publicbtn.canbeentered'), trigger: 'blur'}
        ],
        unlockDay:[
          { required: false, message: this.$t('stakinglist.iptunlockingperiod'), trigger: 'blur' },
          { pattern:/^\d+$/, message:  this.$t('publicbtn.canbeentered'), trigger: 'blur'}

        ],
        lockDay:[
          { required: false, message: this.$t('stakinglist.iptnvestmentperiod'), trigger: 'blur' },
          { pattern:/^\d+$/, message:  this.$t('publicbtn.canbeentered'), trigger: 'blur'}
        ]
            
      }
    };
  },
    computed: {
      crypto(){
　　　　return this.searchuserdata.crypto
　　}
    },
    watch: {
      crypto(newData, oldData){
        if(newData.crypto==oldData.crypto){

        }
        
      },
      
    },
    methods: {
      // 获取接口
      gethuoqu(crypto){
        getUserRequest(crypto,'/staking/getLiveStakeInfo').then(res=>{
          let data =res.data
          if(data.code == 200){
          this.newUserPledgedata.cycle = data.data.cycle
          this.newUserPledgedata.rate = data.data.rate
          this.newUserPledgedata.unlockDay = data.data.unlockDay
          
          }else{
             this.$message({
                    type: 'info',
                    message:data.message
                  }); 
          }
        })
      },
       changeType(event){


        if(event == 1){
          this.disabled.disabledhouqi = true
          this.disabled.disabledsiqi = true
          this.newUserrules.unlockDay[0].required = false
          this.newUserrules.lockDay[0].required = false
          this.disabledratecycle.cycleipt = true
          this.disabledratecycle.rateipt = true
          this.newUserPledgedata.lockDay = ''
          if(this.searchuserdata.crypto){
          let  crypto = {
                  crypto:this.searchuserdata.crypto.toUpperCase()
                }
                this.gethuoqu(crypto)
            }
      
        }else{

          this.disabled.disabledhouqi = true
          this.disabled.disabledsiqi = false
          this.newUserrules.unlockDay[0].required = false
          this.newUserrules.lockDay[0].required = true
          this.disabledratecycle.cycleipt = false
          this.disabledratecycle.rateipt = false
          this.newUserPledgedata.cycle = ''
          this.newUserPledgedata.rate = ''
          this.newUserPledgedata.unlockDay = ''
          
        }
  },
    getuserStaklist(){
        this.loading = true
        getUserRequest(this.userStakingListMsg,'/staking/userStakingList').then(res=>{
            const data = res.data
            if(data.code == 200){
                this.userStakingListdingqi = data.data.dingqi
                this.userStakingListhuoqi =  data.data.huoqi
                    if(this.userStakingListStatus.status == 2){
                        this.userStakingList = data.data.dingqi.list
                        this.userStakingListMsgtotal = data.data.dingqi.total
                    }else if(this.userStakingListStatus.status == 1){
                        this.userStakingList = data.data.huoqi.list
                        this.userStakingListMsgtotal = data.data.huoqi.total
                    }
            }else{
            this.$message({
                message: data.message,
                type: "error"
            })
            }
            this.loading = false 
            })
        },
// 查询
    getuserStaklistbtn(){
    this.userStakingListMsg.page = 1
    this.getuserStaklist()
    },
// 刷新
    getuserStakRefresh(){
    this.userStakingListMsg.page = 1
    this.getuserStaklist()
    },
// 分页
    current_changes(pager) {
    this.userStakingListMsg.page = pager;
    this.getuserStaklist();
    },
//选择定期 活期 
    currentSel(){
        this.loading = true
        this.userStakingListMsg.page = 1
    if(this.userStakingListStatus.status == 2){
        this.userStakingList = this.userStakingListdingqi.list
        this.userStakingListMsgtotal = this.userStakingListdingqi.total
    }else if(this.userStakingListStatus.status == 1){
        this.userStakingList = this.userStakingListhuoqi.list
        this.userStakingListMsgtotal = this.userStakingListhuoqi.total
    }
        this.loading = false
    },

// 赎回
    upUserRedemptionList(userStaking){
    console.log(userStaking)
    },
// 删除
    upUserStakingListdelect(userStaking){
         this.$confirm(this.$t('bulletframe.yndelete'), this.$t('bulletframe.Tips'), {
          confirmButtonText: this.$t('publicbtn.determine'),
          cancelButtonText:  this.$t('publicbtn.cancel'),
        }).then(() => {
          let orderId = userStaking.orderId
            getUserStakingDelete(`/staking/deleteUserStaking/${orderId}`).then(res=>{
              const data = res.data
              if(data.code == 200){
                this.getuserStaklist()
                this.$message({
                  type: 'success',
                  message: data.message
                    });
                }else{
                  this.$message({
                    type: 'info',
                    message:data.message
                  }); 
              }
            })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: this.$t('bulletframe.canceldelete')
          });       
        });


    },
// 修改
    upUserStakingList(cycle ,orderId,rate){
        this.upUserStakingListMsg = true
        this.upUserStakingListdata['cycle'] = cycle
        this.upUserStakingListdata['orderId'] = orderId
        this.upUserStakingListdata['rate'] = rate
    },
// 提交修改
    upUserStakingSubmit(){
        let upUserStakingListdatamsg = JSON.parse(JSON.stringify(this.upUserStakingListdata))
        postUserRequest(upUserStakingListdatamsg ,'/staking/updateUserStaking').then(res=>{
          const data = res.data
            this.upUserStakingListMsg = false
           if(data.code == 200){
            this.getuserStaklist()
            }else{
            this.$message({
                message: data.message,
                type: "error"
            })
            }
        })
    },
// 取消修改
    upUserStakingSubmitReset(){

    this.upUserStakingListMsg = false

    },
// 导出全部数据
    exportexcel(){
    this.userstakinglist.show = true
    },
    exportUserstakingSubmit(){
    if(this.userstakinglist.start&&this.userstakinglist.end){
      if(Number(this.userstakinglist.start)<=Number(this.userstakinglist.end)){
        if(Number(this.userstakinglist.end) - Number(this.userstakinglist.start) <=9){
          let  size 
        if(this.userstakinglist.end == this.userstakinglist.start){
            size = 10
          }else{
            size =  (Number(this.userstakinglist.end) - Number(this.userstakinglist.start) +1)*10
          }
        let userstakinglistcopy = {
        uid:this.userStakingListMsg.uid,
        page:this.userstakinglist.start,
        size:size
        }
    getUserRequest(userstakinglistcopy,'/staking/userStakingList').then(res=>{
            const data = res.data
            if(data.code == 200){
              // 导出分类
            let exportName = this.$t('export.userstakinglist')
        
            let datalist=[]
              if(this.userstakinglist.status == 2){
                datalist = this.userStakingListdingqi.list
                }else if(this.userstakinglist.status == 1){
                datalist = this.userStakingListhuoqi.list
                }

              for(let i = 0 ;i<datalist.length;i++){
              if(datalist[i].type ==1){
              datalist[i].type = this.$t('field.current')   
                }else if(datalist[i].type ==2){
              datalist[i].type = this.$t('field.regular')+'('+ datalist[i].lockDay+$t('field.day')+')'
              }
              if(datalist[i].endDate){
                datalist[i].endDate = this.moment(datalist[i].endDate).format("YYYY-MM-DD HH:mm:ss")
              }else{
                datalist[i].endDate = '-'
              }
              
              datalist[i].num =Math.abs(datalist[i].num) / this.million.toFixed(8)
              datalist[i].interestTotal = datalist[i].interestTotal / this.million.toFixed(8)
              datalist[i].rate = (datalist[i].rate * 100).toFixed(1) +'%'
              if(datalist[i].status == 0){
              datalist[i].status = this.$t('field.inposition')
              }else if(datalist[i].status == 1){
              datalist[i].status = this.$t('field.inredemption')
              }else if(datalist[i].status == -1){
              datalist[i].status = this.$t('field.foreclosure')
              }else if(datalist[i].status == -2){
              datalist[i].status = this.$t('field.close')
              }
            }

            let tableDatatilte = ['userId',                                   'name',                  'username',                 'crypto',                  'type',                    'createdAt',                       'endDate',                    'unlockDay',                      'num'                        ,'interestTotal'                         ,'cycle',                   'rate',                 'status']
                let tableData = [[ this.$t('field.userid'),this.$t('field.upusername'),this.$t('field.cellphones'),this.$t('field.currency'),this.$t('field.type'),this.$t('field.dateofapplication'),this.$t('field.redemptiontime'),this.$t('field.currentrelease'),this.$t('field.pledgequantity'),this.$t('field.accumulatedinterest'),  this.$t('field.poayoutperio'),this.$t('field.interest'),this.$t('field.status'),]]
           
                exportData.exportTable(datalist,tableData,tableDatatilte,exportName)
            this.userstakinglist.show = false
            }else{
                this.$message({
                    message: data.message,
                    type: "error"
                })
            }
            })
        }else{
            this.$message({
              message:this.$t('bulletframe.largerpages'),
              type: "error",
            });
          }
      }else{
          this.$message({
              message:this.$t('bulletframe.startpage'),
              type: "error",
            });
          }
    }else{
            this.$message({
              message:this.$t('bulletframe.ofpages'),
              type: "error",
            });
          }


    },
    exportUserstakingReset(){
    this.userstakinglist.show = false

    },
// 新增质押搜索
    newSearch(){
      if(this.searchuserdata.username&&this.searchuserdata.crypto){
         this.searchuserdata.crypto = (this.searchuserdata.crypto).toUpperCase()
      if(this.newUserPledgedata.type == 1){
          let crypto = {crypto:this.searchuserdata.crypto}
              this.gethuoqu(crypto)
      }
          getUserRequest(this.searchuserdata,'/getUserTradeWalletByCrypto').then(res=>{
            var data = res.data
            if(data.code == 200){
              data = data.data
              this.newUserPledgedata.crypto =(this.searchuserdata.crypto).toUpperCase()
              this.newUserPledgedata.amount = (data.amount-data.lockAmount)/this.million.toFixed(8)
              this.newUserPledgedata.uid = data.uid
              this.newUserPledgedata.username = data.username
              this.newUserPledgedata.name = data.name
              this.newUserPledgedata.userId = data.userId
            }else{
              this.$message({
                  message:data.message,
                  type: "error",
                });
            }
          })
      }else{
        this.$message({
              message:this.$t('bulletframe.usernamecurrency'),
              type: "error",
            });
      }

    },
// 新增质押提交
    newgetuserStakPledgedatasubmit(newUserPledgedata){
      if(this.newUserPledgedata.uid){
        this.$refs[newUserPledgedata].validate((valid) => {
          if(valid){
            let newUserdata = JSON.parse(JSON.stringify(this.newUserPledgedata))
            newUserdata.num = parseInt((Number(newUserdata.num)+0.0000000001)*this.million)
            postUserRequest(newUserdata,'/staking/createUserStakingInfo').then((res=>{
              var data = res.data
                  if(data.code == 200){
                  this.getuserStaklist()
                  }else{
                  this.$message({
                      message:data.message,
                      type: "error",
                    });
                  }
                  this.newgetuserStakPledgefalse=false

            }))

          }
          })
      }else{
    this.$message({
              message:this.$t('bulletframe.searchuser'),
              type: "error",
            });
      }
    
    },
// 新增用户质押关闭
    newgetuserStakPledgefalseclose(){
      
      let newDataArr = Object.keys(this.newUserPledgedata)
          newDataArr.map((item)=>{
          this.newUserPledgedata[item] = ''
      })
      let disabledArr =Object.keys(this.disabled)
          disabledArr.map((item)=>{
          this.disabled[item] = true
      })

      let searchuserdataArr =Object.keys(this.searchuserdata)
          searchuserdataArr.map((item)=>{
          this.searchuserdata[item] = ''
      })
        
        
        this.newgetuserStakPledgefalse = false

    },
  },
  created() {

  },
  mounted() {
    this.getuserStaklist()

  },
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {},
}
</script>

<style scoped>
.pagination {
  text-align: center;
  margin-top: 20px;
}
 .userUpdateMoney {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 9;
}
.userUpdateForm {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 99;
  padding: 30px;
  background: #fff;
  box-shadow: 0px 0px 3px #888;
}
.userUpdateMoney h2 {
  text-align: center;
  font-size: 18px;
}
.newgetuser{
  display: flex;
}
.newgetusermsgdata{
    padding: 20px;
    height: 50vh;
    width: 32vw;
    overflow: auto;
}

</style>